/**
* Copyright (c) By zengqh.
*
* This program is just for fun or demo, in the hope that it  
* will be useful, you can redistribute it and/or modify freely.
*
* Time: 2013/03/04
* File: TextureBuffer2D.h
**/

#pragma once

#include <render_system/BaseRenderSystem/Texture2D.h>

namespace HY
{
class Image;
class OGLTexture2D : public Texture2D
{
	friend class OGLRenderSystem;
public:
	virtual ~OGLTexture2D();

	uint32 getHandle() const;
	virtual bool load(Image* image);

	virtual void bind();
	virtual void unbind();

	virtual bool create(uint32 width, uint32 height, 
		uint32 format, bool mipmap = false, bool compressed = false);
	virtual void release();

protected:
	virtual uint32 getPixelFormatByImage(Image* image);
	virtual uint32 getInternalFormat(uint32 format);
	virtual uint32 getExternalFormat(uint32 format);
	virtual uint32 getDataType(uint32 format);

	virtual uint32 getRowDataSize(uint32 width);
	virtual uint32 getDataSize(uint32 width, uint32 height);

	virtual void updateTexParams();

protected:
	OGLTexture2D();

protected:
	uint32	handle_;
	bool	is_mipmap_;
};
}